import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import { createRouter, createWebHashHistory } from 'vue-router'
import chatRoutes from './modules/chat'
import loginRouters from './modules/login'
import demoRoutes from './modules/demo'
import documentRouters from './modules/document'
import type { RouteRecordRaw } from 'vue-router';
export const rootRoute: RouteRecordRaw = {//Layout下的路由
  path: '/',
  name: 'Layout',
  redirect: '/chat',
  meta: {
    title: '首页'
  },
  component: () => import('@/layout/index.vue'),
  children: [...chatRoutes, ...documentRouters, ...demoRoutes],
}

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    rootRoute,
    ...loginRouters,
  ],
})
router.beforeEach((to, from, next) => {
  NProgress.start()
  next()
})
router.afterEach(() => {
  NProgress.done()
})
export default router
